package com.boilermaker.demo.model;

import com.boilermaker.demo.enums.ResponseStatus;

public class ResponseFactory {
    public static <T> Response<T> success(T data) {
        Response<T> response = new Response<>();
        response.setStatus(ResponseStatus.SUCCESS);
        response.setErrorMessage("");
        response.setData(data);
        return response;
    }

    public static Response<String> fail(String errorMessage) {
        Response<String> response = new Response<>();
        response.setStatus(ResponseStatus.FAIL);
        response.setErrorMessage(errorMessage);
        response.setData("");
        return response;
    }

    public static <T> Response<T> unLogin() {
        Response<T> response = new Response<>();
        response.setStatus(ResponseStatus.UNLOGIN);
        response.setErrorMessage("用户未登录");
        response.setData(null);
        return response;
    }
}
